package com.sg.business.model.dataset;

import org.bson.types.ObjectId;

import com.mobnut.db.model.PrimaryObject;
import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;
import com.sg.business.model.IModelConstants;
import com.sg.business.model.ManagermentCategory;
import com.sg.widgets.commons.dataset.MasterDetailDataSetFactory;

public class ManagermentCategoryDataSet extends MasterDetailDataSetFactory {

	public ManagermentCategoryDataSet() {
		super(IModelConstants.DB, IModelConstants.C_MANAGERMENT_CATEGORY);
	}

	@Override
	protected String getDetailCollectionKey() {
		return ManagermentCategory.F_ORG_ID;
	}

	@Override
	public DBObject getQueryCondition() {
		PrimaryObject po = master;
		ObjectId id = null;
		if (po != null) {
			id = po.get_id();
		}
		return new BasicDBObject().append(ManagermentCategory.F_IS_ROOT, true)
				.append(ManagermentCategory.F_ORG_ID, id);
	}
}
